﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PRO.Common;
using PRO.Config;
using PRO.Entity;
using PRO.User;
using PRO.Product;

namespace web.api.favorite
{
    /// <summary>
    /// fav 的摘要说明
    /// </summary>
    public class fav : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = CVGRequest.GetFormString("c").DEC_Decode(BaseConfigs.DEC_KEY).ToInt(0);
            if (id == 0)
                context.Response.Write("0");
            else
            {
                CookieInfo ui = UserLib.GetUserInfo();
                if (ui.ID == 0)
                    context.Response.Write("-1");
                else
                {
                    FavoriteInfo fi = new FavoriteInfo();
                    fi.PID = id;
                    fi.UserID = ui.ID;
                    fi.Adddate = DateTime.Now;
                    context.Response.Write(FavoriteLib.AddToFavorite(fi));
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}